<template>
  <div>
    <!-- 更改 data 里面的数据 渲染页面 异步代码 -->
    <button @click="getFocus" v-if="flag">点击搜索</button>
    <input v-else type="text" ref="aa" placeholder="输入要搜索的关键案子" />
  </div>
</template>

<script>
export default {
  name: "VueDemoApp",

  data() {
    return {
      flag: true,
    };
  },

  methods: {
    getFocus() {
      this.flag = false;
      this.$nextTick(() => {
        this.$refs.aa.focus();
      });
    },
  },
};
</script>

<style lang="scss" scoped>
</style>